import { WeaSearchGroup, WeaFormItem, WeaTools } from 'ecCom';
import { Button, Row, Col } from 'antd';
import { toJS } from 'mobx';
import { WeaSwitch } from 'comsMobx';
import { inject, observer } from 'mobx-react';

const getKey = WeaTools.getKey;

@observer
class Condition extends React.Component {
  constructor() {
    super();
    // this.formParams = {};
  }

  render() {
    const { condition, form, col, onEnterSearch } = this.props;
    const { isFormInit } = form;
    const group = [];
    // this.formParams = form.getFormParams();
    isFormInit && condition.map((c,indexGroup) => {
      const items = [];
      c.items.map((fields, index) => {
        items.push({
          com: (<WeaFormItem
            ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@prv9fa@${index}`}
            label={`${fields.label}`}
            labelCol={{ span: `${fields.labelcol}` }}
            error={form.getError(fields)}
            tipPosition={'bottom'}
            wrapperCol={{ span: `${fields.fieldcol}` }}
          >
            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@kbpysl@${index}`} fieldConfig={fields} form={form} formParams={form.getFormParams()} onEnterSearch={onEnterSearch} />
          </WeaFormItem>),
          colSpan: 1,
        });
      });
      group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@8msveg@${indexGroup}`} needTigger col={col || 2} title={c.title} showGroup={c.defaultshow} items={items} />);
    });
    return group;
  }
}


export { Condition };
